package com.plugin.dingding.test;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.junit.Test;

//https://blog.csdn.net/weixin_61757095/article/details/126657669
//https://www.bilibili.com/video/BV1ge4y1378c?p=8&vd_source=a5ab8741161e28b7da3ef88e9992d3fc

//https://blog.csdn.net/a8532156/article/details/78427545

//https://plugins.jetbrains.com/
public class ActivitiUtil {

    /**
     * 数据库初始化
     *
     */
//    @Test
    public void generateTable()
    {
        ProcessEngine processEngine = ProcessEngineConfiguration
                .createProcessEngineConfigurationFromResource("activiti.cfg.xml")
                .buildProcessEngine();
        System.out.println(processEngine);
    }


    @Test
    //流程部署  修改ACT_RE_DEPLOYMENT（流程部署表） ACT_GE_PROPERTY（流程定义表）
    public void test() {
        //1、创建（流程引擎）ProcessEngine
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        //2、获取RepositoryServcie(re表的服务层)\
        RepositoryService repositoryService = processEngine.getRepositoryService();
        //3、使用service进行流程的部署，部署bpmn和png
        Deployment deploy = repositoryService.createDeployment()
                .name("出差申请流程")
                .addClasspathResource("bpmn/test.bpmn")
                .addClasspathResource("bpmn/test.png")
                .deploy();

        System.out.println(deploy.getId()
                + "," + deploy.getName());

    }
}
